package com.minivision.sdktestdemo.utils;

import android.app.Activity;
import android.view.Gravity;
import android.view.ViewGroup;
import android.widget.PopupWindow;

import com.minivision.sdktestdemo.R;

/**
 * Created by devtang on 2016/5/26.
 */
public class LoadingWindowUtils {
    private static PopupWindow sPopupWindow;

    public static void release() {
        sPopupWindow = null;
    }

    public static void showProgressBack(Activity context, boolean flag) {
        if (sPopupWindow == null) {
            sPopupWindow = new PopupWindow(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
            sPopupWindow.setContentView(context.getLayoutInflater().inflate(R.layout.layout_update, null));
        }
        if (flag) {
            sPopupWindow.showAtLocation(context.findViewById(R.id.layout_main), Gravity.CENTER, 0, 0);
        } else {
            sPopupWindow.dismiss();
        }
    }
}
